<!DOCTYPE html>
<html lang="zh-cn">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
		<style>
			[v-cloak]{
				display: none;
			}
			.yellow {
				background: yellow;
			}
			#app div {
				width: 300px;
				height: 300px;
				background: red;
				display: none;
			}
		</style>
		<script src="./src/vue.js"></script>
	</head>

	<body>
		<div id="app">
			<button 
				v-for="item,i in news" 
				:class="{yellow: i === showIndex}"
				class="fontSize"
			>
				{{item.title}}
			</button>
			<div 
				:style="{display: showIndex === i ? 'block' : 'none',width: 300 + 200 + 'px'}"
				v-for="item,i in news"
			>
				<p v-for="option in item.list">
					{{option.newsTitle}}
				</p>
			</div>
		</div>
		<script>
			/*
				控制class
					v-bind:class="{class名字：表达式}"
					根据表达式的布尔值，决定这个元素是否要添加这个class
					true 添加
					false 不添加

				控制style
					:style="{display: 1 < 2 ? 'block' : "none"}"
					:style="{width: 1+1+'px'}"
					{
						width: 
						height:
						display:
					}
			*/
			let data = [
				{
					title: '新闻',
					list: [
						{
							newsTitle: '新闻版块1'
						},
						{
							newsTitle: '新闻版块2'
						},
						{
							newsTitle: '新闻版块3'
						}
					]
				},
				{
					title: '娱乐',
					list: [
						{
							newsTitle: '娱乐版块1'
						},
						{
							newsTitle: '娱乐版块2'
						},
						{
							newsTitle: '娱乐版块3'
						}
					]
				},
				{
					title: '体育',
					list: [
						{
							newsTitle: '体育版块1'
						},
						{
							newsTitle: '体育版块2'
						},
						{
							newsTitle: '体育版块3'
						}
					]
				}
			];

			new Vue({
				el: '#app',
				data: {
					news: data,
					showIndex:0  // 控制要显示的面板
				}
			})



		</script>
	</body>
</html>